package com.example.wechattakeaway.controller;

import com.example.wechattakeaway.accessctro.RolePermission;
import com.example.wechattakeaway.form.meroptionsform.InsertDishOptionForm;
import com.example.wechattakeaway.form.meroptionsform.UpdateDishOptionForm;
import com.example.wechattakeaway.service.DishOptionService;
import com.example.wechattakeaway.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/DishOptionController")
@Api(tags = "菜品选项管理模块")
public class DishOptionController {
    @Autowired
    DishOptionService dishOptionService;

    @ApiOperation(value = "添加菜品选项信息",notes = "商家web端")
    @PostMapping("/insertDishOption")
    public ResultVO insertDishOption(InsertDishOptionForm insertDishOptionForm){

        return dishOptionService.insertDishOption(insertDishOptionForm);
    }


    @ApiOperation(value = "编辑菜品选项信息",notes = "商家web端")
    @PostMapping("/updateDishOption")
    public ResultVO updateDishOption(UpdateDishOptionForm updateDishOptionForm){

        return dishOptionService.updateDishOption(updateDishOptionForm);
    }

    @ApiOperation(value = "根据菜品选项id查询对应菜品选项",notes = "小程序端以及商家web端")
    @ApiImplicitParam(name="dishOptionId",value="菜单选项id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectOptionById")
    public ResultVO selectOptionById(@RequestParam("dishOptionId") Integer dishOptionId){

        return dishOptionService.selectOptionById(dishOptionId);
    }

    @ApiOperation(value = "根据菜品选项id查询对应选项以及相关各项选项详情",notes = "小程序端")
    @ApiImplicitParam(name="dishOptionId",value="菜单选项id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectAllById")
    public ResultVO selectAllById(@RequestParam("dishOptionId") Integer dishOptionId){

        return dishOptionService.selectAllById(dishOptionId);
    }

    @ApiOperation(value = "根据菜品id查询对应菜品选项列表（分页）",notes = "商家web端")
    @ApiImplicitParam(name="dishId",value="菜单id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectOptionByDishId")
    public ResultVO selectOptionByDishId(@RequestParam("pageNum") Integer pageNum, @RequestParam("dishId") Integer dishId){

        return dishOptionService.selectOptionByDishId(pageNum,dishId);
    }

    @ApiOperation(value = "根据菜品id查询对应菜品选项列表",notes = "小程序端")
    @ApiImplicitParam(name="dishId",value="菜单id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectByDishId")
    public ResultVO selectByDishId(@RequestParam("dishId") Integer dishId){

        return dishOptionService.selectByDishId(dishId);
    }


    @ApiOperation(value = "根据菜品选项id删除菜品选项",notes = "商家web端")
    @PostMapping("/deleteDishOption")
    public ResultVO deleteDishOption( Integer dishOptionId){

        return dishOptionService.deleteDishOption(dishOptionId);
    }


}
